package com.karson.front.task.statistic;

import com.karson.service.service.impl.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author ZKS
 */
@Component
public class StatisticFlushTask {

    @Autowired
    private LikeStatisticService likeService;

    @Autowired
    private DislikeStatisticService dislikeService;

    @Autowired
    private FavoriteStatisticService favoriteService;

    @Autowired
    private PvStatisticService pvService;

    @Autowired
    private PlayStatisticService playService;

    /**
     * 聚合用户操作
     */
    @Scheduled(fixedRate = 10000)
    public void flushAll() {
        try {
            likeService.flushToDatabase();
            dislikeService.flushToDatabase();
            favoriteService.flushToDatabase();
            pvService.flushToDatabase();
            playService.flushToDatabase();
        }
        catch (Exception e) {
            e.printStackTrace();
        }

    }
}